<template>
  <div  class="login_div">
      <div class="login_form">
          <div class="login_head">欢迎登陆</div>
          <div class="login_body">
            <el-form status-icon  label-width="40px" class="demo-ruleForm">
              <el-form-item label="账号"  prop="pass">
                <el-input type="username" v-model="username"  size="mini" autocomplete="off"></el-input>
              </el-form-item>

              <el-form-item label="密码" prop="checkPass">
                <el-input type="password" v-model="password"  size="mini"  autocomplete="off"></el-input>
              </el-form-item>

              <el-form-item>
                <el-checkbox v-model="rememberMe">记住用户</el-checkbox>
                <el-checkbox v-model="rememberPassword">记住密码</el-checkbox>
              </el-form-item>

              <el-form-item>
                <el-button type="primary" size="mini" @click="userLogin">登陆</el-button>
              </el-form-item>
            </el-form>
          </div>
      </div>
  </div>
</template>

<script>
import {Form, Input, Button, FormItem} from 'element-ui'
import {MUTATION_TYPE_LONGIN} from '../store'
import {mapState, mapMutations} from 'vuex'

export default {
  name: 'login',
  data: () => {
    return {
      rememberMe: 0,
      rememberPassword: 0,
      username: '321201',
      password: '123456'
    }
  },
  methods: {
    userLogin: function () {
      const {username, password, rememberMe, rememberPassword, $router} = this
      this.login({payload: {
        rememberMe: rememberMe,
        rememberPassword: rememberPassword,
        username: username,
        password: password
      },
      $router})
    },
    ...mapMutations({
      login: MUTATION_TYPE_LONGIN
    })
  },
  computed: {
    ...mapState({
      loginUser: 'user'
    })
  },
  components: [Form, FormItem, Input, Button]
}
</script>

<style scoped>
  .login_div{
    position: relative;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-image: url("../assets/login-bg.0899ffa6.jpg");
    background-repeat: no-repeat;
  }
  .login_form{
    position: absolute;
    top: 0;
    bottom: 0;
    right: 180px;
    margin: auto;
    width: 300px;
    height: 330px;
    background-color: #fff;
    border-radius: 3px;
    overflow: hidden;
  }
  .login_head{
    font-size: 15px;
    line-height: 45px;
    border-bottom: 1px solid #cecece;
    padding-left: 20px;
    font-weight: 700;
  }
  .login_body{
    padding: 20px;
  }
</style>
